TK!2
=v
#1
:n
cost
:v
1003.0005866553
:s
o
:c
annual cost of pipe, pump and pumping
:a
cost_2nd
#2
:n
L
:v
1000
:s
i
:u
ft
:d
ft
:c
length of pipeline
#3
:n
D
:v
1.11726818495231
:s
o
:u
in
:d
in
:c
pipe diameter
:a
D_2nd
#4
:n
Q
:v
20
:s
i
:u
gpm
:d
gpm
:c
fluid rate
#5
:n
hp
:v
.205693033277342
:s
o
:c
auxiliary variable
#6
:n
dc%dD
:v
0
:s
i
:c
derivative of cost with respect to D
#7
:n
dhp%dD
:v
-.919513853929484
:s
o
:c
derivative of  hp  with respect to D
=u
=l
#1
:n
D_1st
:d
in
:u
in
:v
.25
.5
.75
1
1.25
1.5
1.75
2
2.25
2.5
2.75
3
3.25
3.5
3.75
4
4.25
4.5
4.75
5
5.25
5.5
5.75
6
E
#2
:n
cost_1st
:v
21205.4373495424
2322.46077935532
1199.92600968847
1015.23963394088
1014.25580393564
1076.3878038614
1169.04652522722
1280.37371441403
1405.10318255663
1540.52289167846
1685.06256140696
1837.72192872449
1997.81195820657
2164.82677090858
2338.37541166917
2518.14314776268
2703.86829450674
2895.32766119215
3092.32701598358
3294.69459870719
3502.27655565002
3714.93362831723
3932.5386859274
4154.97484179372
E
#3
:n
D_2nd
:d
in
:u
in
:v
.25
.287044475701847
.329578124123792
.378414319367648
.43448695960383
.498868326075083
.572789588409921
.657664348370408
.755115672263122
.867007128956061
.9954784270438231
1.14298633265317
1.31235165036323
1.50681316565986
1.7300895804699
1.98645062617284
2.28079871398955
2.6187626841543
3.00680544664253
3.45234757187584
3.96390919483858
4.55127294624867
5.22567102652779
6
E
#4
:n
cost_2nd
:v
21205.4373495424
12595.8937891136
7728.88473512323
4934.24895009567
3302.63727668545
2334.56548145275
1752.77070836336
1401.48029361543
1192.06099357184
1073.50742622561
1016.29662149917
1003.48090026427
1025.73468169597
1078.58724777611
1160.88510705895
1273.96413909939
1421.24817681271
1608.12016109254
1841.98410303459
2132.47737898075
2491.81767143739
2935.28494083424
3481.85048114449
4154.97484179372
E
=f
=r
#1
:r
" ***  Single-variable Optimization, Part 1 (introduction)  ***
:s
C
#3
:r
" Here is a problem from "Engineering Optimization, Methods and Applications"
:s
C
#4
:r
" by Reklaitis, Ravindran and Ragsdell, Wiley-Interscience, 1983, pp. 66-67:
:s
C
#6
:r
" Consider the design of a pipeline for a chemical plant that is  L=1000 ft
:s
C
#7
:r
" long and should carry fluid at the rate of  Q=20 gpm.  The selection of
:s
C
#8
:r
" economic pipe diameter  D (in)  is based on minimizing the annual cost of
:s
C
#9
:r
" pipe, pump, and pumping.  The annual cost of a pipeline with a standard
:s
C
#10
:r
" carbon steel pipe and motor-driven centrifugal pump can be expressed as
:s
C
#12
:r
cost = .45*L + .245*L*D^1.5 + 325*sqrt(hp) + 61.6*hp^.925 + 102
#14
:r
" where
:s
C
#16
:r
hp = L * (4.4e-8*Q^3/D^5 + 1.92e-9*Q^2.68/D^4.68)
#18
:r
" What should be the diameter of the pipe  D  between .25 and 6 inches to
:s
C
#19
:r
" minimize the cost?
:s
C
#21
:r
" Here are the steps we took to solve the problem with TK using the analy-
:s
C
#22
:r
" tical method (i.e. equating the derivative of objective function with
:s
C
#23
:r
" respect to unknown variable to zero):
:s
C
#25
:r
" 1. Entering the equations (see above) and given values (see the Variable.
:s
C
#26
:r
"    Sheet).
:s
C
#28
:r
" 2. List solving for  D = .25, .5, .75, ..., 6  to verify that there is
:s
C
#29
:r
"    a minimum within the given interval of  D .  See the plot 'first'.
:s
C
#30
:r
"    It indicates the existence of a minimum between  D=1  and  1.5 .
:s
C
#32
:r
" 3. The plot 'first' does not show well the down-hill part of the graph and
:s
C
#33
:r
"    the vicinity of the minimum.  We refilled the list  D  using the same
:s
C
#34
:r
"    interval and number of points (24), and Geometric spacing.  We also set
:s
C
#35
:r
"    the Logarithmic Scale option in the Plot Subsheet to X-axis in order to
:s
C
#36
:r
"    zoom in on the portion of interest (see the plot 'second').  The minimum
:s
C
#37
:r
"    can be detected clearly around  D=1.1 .
:s
C
#39
:r
" 4. Next, we take the derivatives.  We copy the above rules and edit them 
:s
C
#40
:r
"    as appropriate, using the formulas  d(x^n)/dx = n*x^(n-1)  and  
:s
C
#41
:r
"    d(f(g(x)))/dx = d(f(g))/d(g(x)) * d(g(x))/dx .  The  %  symbol is used
:s
C
#42
:r
"    instead of  /  to denote the derivatives:
:s
C
#44
:r
dc%dD = .245*L*1.5*D^.5 + 325*.5*hp^-.5*dhp%dD + 61.6*.925*hp^-.075*dhp%dD
#45
:r
dhp%dD = L * (-5*4.4e-8*Q^3/D^6 - 4.68*1.92e-9*Q^2.68/D^5.68)
#47
:r
" 5. Now we can assign an input value  dc%dD=0  and a guess value  D=1 ,
:s
C
#48
:r
"    and solve (F9).  TK comes with the final answer in five iteration
:s
C
#49
:r
"    steps.  The solution may be seen in the Variable Sheet.  When we did
:s
C
#50
:r
"    this for the first time, it took less than 5 minutes from reading the
:s
C
#51
:r
"    assignment to arriving at the answer (this story was written later).
:s
C
#53
:r
" Note: See the models OPTIM1B, OPTIM1C and OPTIM1D showing alternative ways
:s
C
#54
:r
" of solving the same problem.  OPTIM1B shows the use of numerical approxi-
:s
C
#55
:r
" mation of derivatives, and OPTIM1C uses the golden section search.
:s
C
#56
:r
" OPTIM1D employs the inverse parabolic interpolation method.
:s
C
=p
#1
:n
first
:t
Line chart
:d
EGA
:i
""
:s
Yes
:z
None
:g
No
:l
None
:h
"Pipe Diameter"
:v
"Cost"
:x
D_1st
:u
#1
:y
cost_1st
:f
1
:p
Lines
:c
"*"
E
#2
:n
second
:t
Line chart
:d
EGA
:i
""
:s
Yes
:z
None
:g
No
:l
X-axis
:h
"Pipe Diameter"
:v
"Cost"
:x
D_2nd
:u
#1
:y
cost_2nd
:f
1
:p
Lines
:c
"*"
E
=t
=n
=g
#1
:c
.000001
:i
10
:v
Yes
:l
60
:f
66
:m
0
:w
80
:b
Yes
:a
Yes
:r
Yes
:h
No
:t
1
:n
Yes
:d
LPT1
%Tr,f,0,1,0,1,0
